//
//  UIView+ZHExtension.h
//  kunlun
//
//  Created by zhusanbao on 2020/10/5.
//  Copyright © 2020 zhusanbao. All rights reserved.
//

#import <UIKit/UIKit.h>

static inline void JellyAnimationWithViewComplete(UIView * _Nullable view, void(^ _Nullable completeHandler)(BOOL finished)){
    [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
        view.transform = CGAffineTransformScale(view.transform, 0.92, 0.92);
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
            view.transform = CGAffineTransformIdentity;
        } completion:^(BOOL finished) {
            if (completeHandler) {
                completeHandler(finished);
            }
        }];
    }];
}
static inline void SoftSpringPoperAnimationWithCodeComplete(void(^ _Nullable animateCode)(void), void(^ _Nullable completeHandler)(BOOL finished)){
    if (!animateCode) {
        if (completeHandler) {completeHandler(NO);}
        return;
    }
    [UIView animateWithDuration:0.5 delay:0 usingSpringWithDamping:0.7 initialSpringVelocity:1 options:UIViewAnimationOptionCurveEaseOut animations:^{
        if (animateCode) {
            animateCode();
        }
    } completion:^(BOOL finished) {
        if (completeHandler) {
            completeHandler(finished);
        }
    }];
}


@interface UIView (ZHAction)

@property (nonatomic, strong) NSDictionary * _Nullable zh_action;
/** enlarge or shrink touch area  */
@property (assign, nonatomic) UIEdgeInsets zh_enlarge;
/// 手势代理实现类
@property (strong, nonatomic) id gestureDelegate;
/** user manualy handle this action  */
- (BOOL)customRunAction:(NSDictionary *_Nullable)action;
/** manualy excecute an action to self's viewController  */
- (void)runZHAction:(NSDictionary *_Nonnull)action;

@end

@interface UIView (ZHExtension)

@end
